package cn.jinjimi.app.main.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.WindowManager;

import cn.jinjimi.base.preference.PreferenceManager;
import cn.jinjimi.app.R;
import cn.jinjimi.app.controller.AppConfigureController;
import cn.jinjimi.app.managers.LocalPushActInfoManager;
import cn.jinjimi.app.main.extend.BaseActivity;
import cn.jinjimi.app.main.fragment.StartFragment;
import cn.jinjimi.app.bean.SharePrefKeys;

/**
 * @author zhenhua
 */
public class StartActivity extends BaseActivity {

    public final static String TAG = StartActivity.class.getSimpleName();

    @Override
    protected void beforeInitView() {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.activity_start);
    }

    @Override
    protected void initial() {
        PreferenceManager.setData(SharePrefKeys.PREF_APP_HAVE_IN, true);

        FragmentManager fm = this.getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        ft.add(R.id.content_fragment, new StartFragment());
        ft.commit();
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //fix 部分小米手机点击home键再点应用图标需要重启的问题
        if (getIntent() != null && (getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
            finish();
            return;
        }

        //配置本地推送
        LocalPushActInfoManager.PushAllSet(this);

        //禁止滑动返回
        setSwipeEnabled(false);

        //启动接口
        AppConfigureController.start(this);

    }

    @Override
    protected void onStart() {
        super.onStart();
    }

    @Override
    public void onBackPressed() {

    }
}
